package com.qdlc.p2p.biz.executer.impl;

import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.qdlc.p2p.biz.executer.BaseExecuter;
import com.qdlc.p2p.common.constant.Global;
import com.qdlc.p2p.common.constant.LogTplNid;
import com.qdlc.p2p.common.util.BigDecimalUtil;
import com.qdlc.p2p.common.util.NumberUtil;

/**
 * 还款投资人收到还款本金
 *
 * @author cx
 * @version 2.0
 * @since 2014-5-21
 */
@Service
@Scope(value=ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class BorrowRepayTenderCapitalExecuter extends BaseExecuter {

    @Override
    public void handleAccountWithLog() {
        Object experienceObj = Global.getTransfer().get("experienceMoney");
        double experienceMoney = 0;
        if (null != experienceObj) {
			experienceMoney = NumberUtil.getDouble(experienceObj.toString());
		}
		Global.setTransfer(LogTplNid.LOG_TPL_KEY, LogTplNid.CAPITAL_COLLECT);
		Global.setTransfer("web_url", WEB_URL);
		double collection = BigDecimalUtil.add(super.money, experienceMoney);
		accountService.revokeCapital(super.user.getUserId(), super.toUser.getUserId(), super.money, collection);
    }
}
